#include <bits/stdc++.h>
#include "graph.h"
using namespace std;
using ll=long long;
mt19937 rd(random_device{}());
const int INF=998244353;
int Ans[310],dis[310][310],back[310],now,n,x,M;
vector<int> V[310],son[310],bc[310],Z[310];
int fa[310],fax[310],du[310],cnt,all=1;
int res[310][310];
int st[310];
void floyd()
{
   for(int k=1;k<=n;k++)
      for(int i=1;i<=n;i++)
         for(int j=1;j<=n;j++)
            dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
   return;
}
int init(int x,int ffa)
{
   if(Color()==2){Move(LastRoad(),2);return x;}
   if(Color()==3){Move(LastRoad(),3);return 0;}
   if(ffa) x=++n,fax[x]=ffa,fa[x]=LastRoad(),Move(fa[x],2),Move(LastRoad(),2);
   du[x]=NumberOfRoads();
   for(int i=1,to;i<=du[x];i++)
   {
      if(i==fa[x]) continue;
      Move(i,2),to=init(x,x);son[x].push_back(to);
      if(to==x) bc[x].push_back(i),res[x][i]=1;
      else if(to>0) dis[x][to]=dis[to][x]=1;
      else Z[x].push_back(i),res[x][i]=1;
   }
   if(x!=1) Move(fa[x],3);
   return x;
}
void dfs(int x,int ffa)
{
   int cnt=0,las=0,y=x;
   for(int i=1;i<=200;i++) st[i]=0;
   if(x==n) all=0;
   for(auto to:bc[x])
   {
      res[x][to]=1;Move(to,1);
      st[LastRoad()]=1,Move(LastRoad(),2);cnt++;
   }
   while(cnt)
   {
      if(x==y) Move(fa[y],1);
      else Move(fa[y],3);y=fax[y];
      if(Color()==2) dis[x][y]=dis[y][x]=1,cnt--;
   }
   if(x!=y)
   {
      if(!all) return;
      for(auto to:Z[y])
      {
         if(!st[to]) continue;
         Move(to,3);if(Color()==1) break;
         Move(LastRoad(),3);
      }
   }
   int now=-1;
   for(int i=1,to;i<=du[x];i++)
   {
      if(i==fa[x]) continue;now++;
      if(res[x][i]) continue;
      Move(i,3),dfs(son[x][now],x);
   }
   if(x!=1&&all) Move(fa[x],3);return;
}
void Inspect(int R)
{
   for(int i=1;i<=200;i++) for(int j=1;j<=200;j++) dis[i][j]=INF;
   for(int i=1;i<=200;i++) dis[i][i]=0;int p=rd()%4+5;if(!(p&1)) p++;
   for(int i=1;i<=p;i++) Move(rd()%NumberOfRoads()+1,1);
   now=n=1;init(1,0);
   for(int i=1;i<=n;i++) M+=du[i];M/=2;
   dfs(1,0);floyd();
   for(int i=1;i<=n;i++)
      for(int j=i+1;j<=n;j++) if(dis[i][j]!=INF) Ans[dis[i][j]]++;
   for(int i=1;i<=R;i++) Answer(i,Ans[i]);
   // cerr<<"@M:"<<M<<endl;
   return;
}